package com.qf.service.impl;

import com.qf.entity.TbGoodDetail;
import com.qf.dao.TbGoodDetailDao;
import com.qf.service.TbGoodDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TbGoodDetail)表服务实现类
 *
 * @author makejava
 * @since 2021-04-06 09:44:32
 */
@Service("tbGoodDetailService")
public class TbGoodDetailServiceImpl implements TbGoodDetailService {
    @Resource
    private TbGoodDetailDao tbGoodDetailDao;

    /**
     * 通过ID查询单条数据
     *
     * @param gdId 主键
     * @return 实例对象
     */
    @Override
    public TbGoodDetail queryById(Integer gdId) {
        return this.tbGoodDetailDao.queryById(gdId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TbGoodDetail> queryAllByLimit(int offset, int limit) {
        return this.tbGoodDetailDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tbGoodDetail 实例对象
     * @return 实例对象
     */
    @Override
    public TbGoodDetail insert(TbGoodDetail tbGoodDetail) {
        this.tbGoodDetailDao.insert(tbGoodDetail);
        return tbGoodDetail;
    }

    /**
     * 修改数据
     *
     * @param tbGoodDetail 实例对象
     * @return 实例对象
     */
    @Override
    public TbGoodDetail update(TbGoodDetail tbGoodDetail) {
        this.tbGoodDetailDao.update(tbGoodDetail);
        return this.queryById(tbGoodDetail.getGdId());
    }

    /**
     * 通过主键删除数据
     *
     * @param gdId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer gdId) {
        return this.tbGoodDetailDao.deleteById(gdId) > 0;
    }

    @Override
    public int queryCount(int goodId, int[] detailIds) {
        return tbGoodDetailDao.queryCount(goodId,detailIds);
    }
}